import * as api from "../../../api/gw/index.js";
import axios from "axios";
//获取钱包余额
export const getWalletBalance = function () {
    let options = {
        url: window.api.customer_host + api.WALLET_BALANCE,
        method: "get",
        headers: {sessionId: localStorage.getItem("sessionId")}
    }
    return axios(options);
}
//通知后台使用钱包付款
export const walletPay = function (orderNo) {
    let opt = {
        url: window.api.trade_host + api.WALLET_NOTICE + `/${orderNo}`,
        method: "post",
        headers: {sessionId: localStorage.getItem("sessionId")}
    }
    return axios(opt);
}

//获取支付列表
export const getPaywayList = () => {
    let url = window.api.trade_host + api.PAYWAY_LIST;
    return axios.get(url, {
        headers: {sessionId: localStorage.getItem("sessionId")}
    });
}

//获取H5支付信息
export const getOrderInfoByH5Pay = function (params) {
    let options = {
        url: window.api.trade_host + api.OTHER_PAY,
        method: "post",
        headers: {
            sessionId: localStorage.getItem("sessionId"),
            "Content-Type": "application/x-www-form-urlencoded"
        },
        data: params,
        transformRequest: [function (data) {
            let requestData = ''
            for (let it in data) {
                requestData += encodeURIComponent(it) + '=' + encodeURIComponent(data[it])
            }
            return requestData;
        }]
    }
    return axios(options);
}